package com.demo2do.fms.entity.data.cost;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.demo2do.core.format.PersistentFormat;
import com.demo2do.fms.entity.authority.Organization;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 汽车油价
 * 
 * @author Ysy
 *
 */
@Entity
@Table(name = "TBL_TRUCK_OIL_PRICE")
public class OilPrice {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    /** 油价类型*/
    private Long oilType;
    
    /** 油价*/
    private BigDecimal price;
    
    /** 有效日期*/
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape=JsonFormat.Shape.STRING , pattern ="yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
    private Date effectDate;
    
    /** 开始日期*/
    @JsonFormat(shape=JsonFormat.Shape.STRING , pattern ="yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
    private Date startDate;
    
    /** 结束日期*/
    @JsonFormat(shape=JsonFormat.Shape.STRING , pattern ="yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
    private Date endDate;
    
    /** 创建日期*/
    private Date createDate;
    
    /** 创建者*/
    private Long creatorId;
    
    /** 油价地点*/
    private Long oilPlace;
    
    /** 所属公司 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = "organization_id", referencedColumnName = "id")
    @JsonIgnore(value = true)
    @PersistentFormat
    private Organization organization;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * 
     * the default constructor
     */
    public OilPrice() {

    }
    
    /**
     * 
     * @return
     */
    public OilPrice init(){
    	this.startDate = new Date();
    	this.createDate = new Date();
    	this.oilPlace = new Long(0);
    	return this;
    }
    
    /**
     * 
     * @param operator
     * @return
     */
    public OilPrice operator(Long operator){
        this.creatorId=operator;
        return this;
    }
    
    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the oilType
     */
    public Long getOilType() {
        return oilType;
    }

    /**
     * @return the price
     */
    public BigDecimal getPrice() {
        return price;
    }

    /**
     * @return the effectDate
     */
    public Date getEffectDate() {
        return effectDate;
    }

    /**
     * @return the startDate
     */
    public Date getStartDate() {
        return startDate;
    }

    /**
     * @return the endDate
     */
    public Date getEndDate() {
        return endDate;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @return the createDate
     */
    public Date getCreateDate() {
        return createDate;
    }

    /**
     * @return the creatorId
     */
    public Long getCreatorId() {
        return creatorId;
    }

    /**
     * @return the oilPlace
     */
    public Long getOilPlace() {
        return oilPlace;
    }

    /**
     * @return the organization
     */
    public Organization getOrganization() {
        return organization;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param oilType the oilType to set
     */
    public void setOilType(Long oilType) {
        this.oilType = oilType;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    /**
     * @param effectDate the effectDate to set
     */
    public void setEffectDate(Date effectDate) {
        this.effectDate = effectDate;
    }

    /**
     * @param startDate the startDate to set
     */
    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    /**
     * @param endDate the endDate to set
     */
    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

    /**
     * @param createDate the createDate to set
     */
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    /**
     * @param creatorId the creatorId to set
     */
    public void setCreatorId(Long creatorId) {
        this.creatorId = creatorId;
    }

    /**
     * @param oilPlace the oilPlace to set
     */
    public void setOilPlace(Long oilPlace) {
        this.oilPlace = oilPlace;
    }

    /**
     * @param organization the organization to set
     */
    public void setOrganization(Organization organization) {
        this.organization = organization;
    }
}
